#ifndef MYMESSAGES_H
#define MYMESSAGES_H

#include "MyDefinitions.h"
#include <list>
#include <string>

class MyGame;

/*! 
 *  \class messageObject
 *  \brief Parent class for messageInstance and effectInstance, so they can be handled as one type of objects
 *  \author Peter Kosa
 *  \version 1.52
 *  \date    2006-2008
 */
class messageObject {
public:
	MyGame* parent;
	virtual bool move(int _t){return false;}
	~messageObject(){}
};


/*! 
 *  \class messageInstance
 *  \brief Message to be displayed on the screen 
 *  \author Peter Kosa
 *  \version 1.52
 *  \date    2006-2008
 */
class messageInstance : public messageObject {
public:
	//time left to be shown on the screen
	int time, timeInitial;
	//surface to hold the message text
	SDL_Surface* messageSheet;
	//color of the message text
	SDL_Color *c1, *c2;
	//position on the screen
	int pos_x, pos_x2, pos_y, pos_y2;
	//text of the message
	char* text;
	messageInstance(){}
	/*! this message with text tx will travel from [_x1,_y1] to [_x2,_y2] in time _t, changing color from _c1 in the beginning to _c2 in the end */
	messageInstance(int t,int _x1,int _y1,int _x2,int _y2,char* tx, SDL_Color* _c1, SDL_Color* _c2, MyGame* _parent) 
	{
		time = t;			
		timeInitial = t;	
		pos_x = _x1;		
		pos_y = _y1; 		
		pos_x2 = _x2;
		pos_y2 = _y2;
		text = new char[50];
		strcpy(text, tx);
		c1 = _c1;
		c2 = _c2;
		parent = _parent;
	}
	/*! this message with text tx will travel on the right side of the screen, from top to bottom, in time t and will be of color _c1 */ 
	messageInstance(int t, char* tx, SDL_Color* _c1, MyGame* _parent) 
	{
		time = t;			
		timeInitial = t;	
		text = new char[100];
		strcpy(text, tx);
		c1 = _c1;
		parent = _parent;
	}
	/*! returns delta time */
	double get_d_time()
	{
		return (double(timeInitial-time))/timeInitial;
	}
	/*! moves message to next position and draws it */
	bool move(int _t);	
	~messageInstance(){
		delete(text);
		SDL_FreeSurface(messageSheet);}
};
/*!
 *  \struct effectInstance 
 *  \brief not implemented yet 
 *  \author Peter Kosa
 *  \version 1.52
 *  \date    2006-2008
 */
class effectInstance : public messageObject {
public:
	//surface with the effect
	SDL_Surface* effectSheet;
	//size of the effect
	int size_w, size_h;
	//pos of the exxect
	int pos_x, pos_y;
	//time of one frame
	int act_frame_time, frame_time, number_of_frames, act_frame;

	effectInstance(std::string s, int s_x,int s_y, int p_x,int p_y, int _number_of_frames, int time_of_effect, MyGame* _p);
	
	bool move(int _t);
	~effectInstance(){
		SDL_FreeSurface(effectSheet);}
};

/*! 
 *  \class MyMessages
 *  \brief Encapsulated all the game messaged
 *  \author Peter Kosa
 *  \version 1.52
 *  \date    2006-2008
 */
class MyMessages{
	public:		
		MyMessages(MyGame* parent);
		~MyMessages();
    
    //pointer to parent game
		MyGame* parent;							
		/*! list of all messages (and effects) */ 
		std::list<messageObject*> messageSwarm;	
    /*! init the list for messages */
		void init_messages();					
		/*! clears all messages in the list */
		void clean_messages();				
		/*! add free message */ 
		void add_text_message(int t,int x1,int y1,int x2,int y2,char* tx, SDL_Color* c1, SDL_Color* c2);	
		/*! add right-side bound message */
		void add_border_text_message(int _time, char* tx, SDL_Color* _c1);  
		/*! add new effect - not implemented yet */
		void add_effect_message();				 
		/*! move and draw all messages */
		void draw_messages(int _t);		
		/*! show message about player death */	
		void death_message();					
	private:
};
#endif
